﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Threading.Tasks;
using ArchivesAdmin.Util;
using ArchivesAdmin.Util.Extension;
using ArchivesAdmin.Util.Model;
using ArchivesAdmin.Entity.DataManage;
using ArchivesAdmin.Model.Param.DataManage;
using ArchivesAdmin.Service.DataManage;

namespace ArchivesAdmin.Business.DataManage
{
    /// <summary>
    /// 创 建：admin
    /// 日 期：2021-06-14 17:39
    /// 描 述：业务类
    /// </summary>
    public class AjbxxbBLL
    {
        private AjbxxbService ajbxxbService = new AjbxxbService();

        #region 获取数据
        public async Task<TData<List<AjbxxbEntity>>> GetList(AjbxxbListParam param)
        {
            TData<List<AjbxxbEntity>> obj = new TData<List<AjbxxbEntity>>();
            obj.Result = await ajbxxbService.GetList(param);
            obj.TotalCount = obj.Result.Count;
            obj.Tag = 1;
            return obj;
        }

        public async Task<TData<List<AjbxxbEntity>>> GetPageList(AjbxxbListParam param, Pagination pagination)
        {
            TData<List<AjbxxbEntity>> obj = new TData<List<AjbxxbEntity>>();
            obj.Result = await ajbxxbService.GetPageList(param, pagination);
            obj.TotalCount = pagination.TotalCount;
            obj.Tag = 1;
            return obj;
        }

        public async Task<TData<AjbxxbEntity>> GetEntity(long id)
        {
            TData<AjbxxbEntity> obj = new TData<AjbxxbEntity>();
            obj.Result = await ajbxxbService.GetEntity(id);
            if (obj.Result != null)
            {
                obj.Tag = 1;
            }
            return obj;
        }
        #endregion

        #region 提交数据
        public async Task<TData<string>> SaveForm(AjbxxbEntity entity)
        {
            TData<string> obj = new TData<string>();
            await ajbxxbService.SaveForm(entity);
            obj.Result = entity.Id.ParseToString();
            obj.Tag = 1;
            return obj;
        }

        public async Task<TData> DeleteForm(string ids)
        {
            TData obj = new TData();
            await ajbxxbService.DeleteForm(ids);
            obj.Tag = 1;
            return obj;
        }
        #endregion

        #region 私有方法
        #endregion
    }
}
